#ifndef EVDEV_H
#define EVDEV_H
//******************************************************************************
//*this code is protected by the GNU affero GPLv3
//*author:Sylvain BERTRAND <sylvain.bertrand AT gmail dot com>
//*                        <digital.ragnarok AT gmail dot com>
//******************************************************************************
#define LINUX_EVDEVS_MAX 32//see linux documentation
#define LWL_EVDEV_EVS_MAX 4//an "input event" is several *evdev* (input) events 
#define LWL_EVDEV_LONG_BITS (sizeof(long)<<3)
#define LWL_EVDEV_DEVNODE_SZ 64
struct evdev{
  u8 devnode[LWL_EVDEV_DEVNODE_SZ];
  i fd;
  l ev_bits[((EV_MAX/LWL_EVDEV_LONG_BITS)+1)];
  l key_bits[((KEY_MAX/LWL_EVDEV_LONG_BITS)+1)];
  l rel_bits[((REL_MAX/LWL_EVDEV_LONG_BITS)+1)];
  l led_bits[((LED_MAX/LWL_EVDEV_LONG_BITS)+1)];
  struct input_event evs[LWL_EVDEV_EVS_MAX];//evdev read buffer
  s32 seat_name;//an event device holds a ref on a seat
};

#ifdef LWL_EVDEV_C
struct evdev evdevs[LINUX_EVDEVS_MAX];
#else
extern struct evdev evdevs[LINUX_EVDEVS_MAX];
#endif

void lwl_evdevs_init(i srv_ep_fd);
s8 lwl_evdev_new(void *devnode,s32 seat_name);
void lwl_evdev_close(struct evdev *d);
void lwl_evdev_kill(struct evdev *d);
void lwl_evdev_remove(void *devnode);
u8 lwl_evdev_has_pointer(struct evdev *d);
u8 lwl_evdev_has_keyboard(struct evdev *d);
#endif
